package com.etime.shycourse.controller.coupons;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.etime.shycourse.config.PageMessage;
import com.etime.shycourse.dto.CouponreciveDto;
import com.etime.shycourse.services.coupons.interfaces.CouponreciveServices;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 *
 * @author wb
 * @since 2022-03-15
 */
@Api(tags = "后台-优惠券管理-优惠券领取日志")
@RestController
@RequestMapping("/sys/couponrecive")
public class CouponreciveController {
    @Autowired
    private CouponreciveServices service;

    @ApiOperation("优惠券领取记录 分页")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "第几页"),
            @ApiImplicitParam(name = "pageSize", value = "每页多少行"),
            // 复用
            @ApiImplicitParam(name = "coupontitle", value = "可根据优惠劵名模糊搜索"),
            @ApiImplicitParam(name = "couponrecivestate", value = "优惠券使用状态"),
            @ApiImplicitParam(name = "couponno", value = "优惠券编号 "),
    })
    @GetMapping("/page")
    public PageMessage<CouponreciveDto> selectCouponReceivePage(CouponreciveDto dto, Long pageNum, Long pageSize) {
        PageMessage<CouponreciveDto> msg = new PageMessage<> ();
        Page<CouponreciveDto> data = service.selectCouponReceivePage (dto, pageNum, pageSize);
        if (data != null) {
            msg.setCode (1);
            msg.setPagedata (data);
        } else {
            msg.setCode (0);
            msg.setMsg ("没有查询到数据");
        }
        return msg;
    }
}

